home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xsok-1.000 / xsok-1 / xsok-1.01 / src / Xaw-help.c < prev    next >
C/C++ Source or Header  |  1994-11-24  |  3KB  |  87 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    Xsok version 1.00 -- module Xaw-help.c                     */
  5. /*                                         */
  6. /*    Online help functions for the Athena Widget interface.             */
  7. /*    Written by Michael Bischoff (mbi@mo.math.nat.tu-bs.de)             */
  8. /*    November-1994                                 */
  9. /*    see COPYRIGHT.xsok for Copyright details                 */
  10. /*                                         */
  11. /*                                         */
  12. /*****************************************************************************/
  13. #ifdef ONLINE_HELP
  14. #include "X-sok.h"
  15. #include "Tableau.h"
  16.  
  17. #include <X11/Shell.h>
  18. #include <X11/Xaw/MenuButton.h>
  19. #include <X11/Xaw/SimpleMenu.h>
  20. #include <X11/Xaw/Command.h>
  21. #include <X11/Xaw/AsciiText.h>
  22. #include <X11/Xaw/Form.h>
  23. #include <X11/Xaw/Sme.h>
  24. #include <X11/Xaw/SmeBSB.h>
  25.  
  26. static int help_active = 0;
  27. static Widget help, helppaned, helppanel, helptext, helpclose;
  28. extern const char *keyfilename;    /* from X-widget.c */
  29.  
  30. static void selecttopic(Widget w, XtPointer number, XtPointer garbage) {
  31.     char filename[200];
  32.     const char *s = XtName(w);
  33.     Arg Args[2];
  34.     int i = atoi(s+4);
  35.  
  36.     sprintf(filename, "%s/%s/%s.help", xsokdir, langdir,
  37.         i ? rulepool[i-1] : keyfilename);
  38.     XtSetArg(Args[0], XtNstring, filename);
  39.     XtSetArg(Args[1], XtNtype, XawAsciiFile);
  40.     XtSetValues(helptext, Args, 2);
  41. }
  42.  
  43. void create_help(void) {
  44.     Widget topicsmenu, topicsbutton, w;
  45.     Arg Args[1];
  46.     help         = XtCreatePopupShell("help", transientShellWidgetClass, toplevel, NULL, 0);
  47.     helppaned    = XtCreateManagedWidget("helppaned",    panedWidgetClass,      help,         NULL, ZERO);
  48.     helppanel      = XtCreateManagedWidget("helppanel",    boxWidgetClass,        helppaned,    NULL, ZERO);
  49.     helptext     = XtCreateManagedWidget("helptext",    asciiTextWidgetClass,  helppaned,    NULL, ZERO);
  50.     XtSetArg(Args[0], XtNmenuName, "topicsmenu");
  51.     topicsbutton = XtCreateManagedWidget("Topic",       menuButtonWidgetClass, helppanel,    Args, 1);
  52.     topicsmenu   = XtCreatePopupShell("topicsmenu",     simpleMenuWidgetClass, topicsbutton, NULL, ZERO);
  53.     helpclose     = XtCreateManagedWidget("Close Help",    commandWidgetClass,    helppanel,    NULL, ZERO);
  54.     XtAddCallback(helpclose, XtNcallback, popdown_help, NULL);
  55.  
  56.     XtSetArg(Args[0], XtNlabel, TXT_HELP_KEYS);
  57.     w = XtCreateManagedWidget("Help0", smeBSBObjectClass, topicsmenu, Args, 1);
  58.     XtAddCallback(w, XtNcallback, selecttopic, NULL);
  59.     {   const char **rp;
  60.     for (rp = rulepool; *rp; ++rp) {
  61.         char n[8], s[40];
  62.         sprintf(n, "Help%d", rp-rulepool+1);
  63.         XtSetArg(Args[0], XtNlabel, s);
  64.         sprintf(s, TXT_HELP_RULES, *rp);
  65.         w = XtCreateManagedWidget(n, smeBSBObjectClass, topicsmenu, Args, 1);
  66.         XtAddCallback(w, XtNcallback, selecttopic, NULL);
  67.     }
  68.     }
  69.  
  70. }
  71.  
  72. void popup_help(void) {
  73.     if (help_active)
  74.     return;        /* request pending => deny another one */
  75.     help_active = 1;
  76.     XtPopup(help, XtGrabNone);
  77. }
  78.  
  79. void popdown_help(Widget w, XtPointer a, XtPointer b) {
  80.     if (!help_active)
  81.     return;        /* request pending => deny another one */
  82.     help_active = 0;
  83.     XtPopdown(help);
  84. }
  85.  
  86. #endif
  87.